﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;

namespace ZX.WebApp.Crm
{
    /// <summary>
    /// BMsgReplyOne 的摘要说明
    /// 2015/01/22   谭欠祥
    /// 为MsgReplyOne表服务
    /// 为我所以的js提供方法
    /// </summary>
    public class BMsgReplyOne : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            string entity = context.Request.QueryString["entity"].ToString();
            switch (entity)
            {
                case "DatSysNewsMonth"://删除客户信息【逻辑】
                    string sql = "update DatSysNewsMonth set ISDelete=1 where id='" + context.Request.QueryString["ID"].ToString() + "'";
                    context.Response.ContentType = "text/plain";
                    context.Response.Write(ExecuteNonQuery(sql).ToString());
                    break;
                default:
                    break;
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }




        /// <summary>
        /// 增删改
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        private int ExecuteNonQuery(string sql)
        {
            #region 访问数据库代码
            //打开数据库
            string connString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnString"].ToString();
            try
            {
                using (SqlConnection conn = new SqlConnection(connString))
                {
                    conn.Open();
                    SqlCommand com = new SqlCommand(sql, conn);
                    int result = com.ExecuteNonQuery();
                    com.Dispose();
                    conn.Close();
                    return result;
                }
            }
            catch (Exception)
            {
                throw;
            }
            #endregion
        }

    }
}